<admintpl file="header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="">服务商列表</a></li>
        <li><a href="{:U('Service/Adminindex/edit_sp')}" target="_self">新建服务商</a></li>
    </ul>
    <form class="well form-search" method="post" action="{:U('Adminindex/index')}">
        状态：
        <select name="status" style="width: 120px;">
            <option value='0'>请选择状态</option>
            <option value='1' <?php if($status == 1) {?> selected <?php }?>>上线</option>
            <option value='2' <?php if($status == 2) {?> selected <?php }?>>下线</option>
        </select> &nbsp;&nbsp;
        项目名称：
        <input type="text" name="company_name" style="width: 150px;" value="{$company_name|default=''}" placeholder="请输入项目名称">
        <input type="submit" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:U('Adminindex/index')}">清空</a>
    </form>
    <form class="js-ajax-form" action="" method="post">
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="50">{:L('SP_SORT')}</th>
                <th width="50">ID</th>
                <th width="150">{:L('SP_PROJECT_NAME')}</th>
                <th width="50">{:L('SP_STATUS')}</th>
                <th width="50">{:L('SP_ESTABLISHED_TIME')}</th>
                <th width="70">{:L('SP_OP')}</th>
            </tr>
            </thead>
            <foreach name="sp_lists" item="vo">
                <tr>
                    <td><input class="input input-order sp_sort" type="text" size="5" value="{$vo.sort}" old-value="{$vo.sort}" sp-id="{$vo.id}"></td>
                    <td><b>{$vo.id}</b></td>
                    <td>
                        <a data-href="{:U('Adminindex/service_info', ['id' => $vo['id']])}" target="">{$vo.company_name}</a>
                    </td>
                    <td>
                        <if condition="$vo['status'] == 1">
                            上线
                        <else/>
                            下线
                        </if>
                    </td>
                    <td>{$vo['modify_time'] > 0 ? date('Y-m-d H:i:s', $vo['modify_time']) : ''}</td>
                    <td>
                        <a href="{:U('Adminindex/edit_sp',array('id' => $vo['id']))}">{:L('EDIT')}</a> |
                        <a href="{:U('Adminindex/edit_sp',array('id' => $vo['id'], 'delete' => 1))}" class="sp_delete" sp-id="{$vo.id}">{:L('DELETE')}</a>
                    </td>
                </tr>
            </foreach>
        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>
    $(function () {
        $('.sp_sort').change(function () {
            var new_sort = $(this).val();
            var old_sort = $(this).attr('old-value');
            if (new_sort > 0 && new_sort != old_sort) {
                var id = $(this).attr('sp-id');
                $.post("{:U('Adminindex/changeSp_sort')}", {id : id, sort : new_sort}, function (result) {
                    if (result.status) {
                        alert(result.info);
                        $('.sp_sort').attr('old-value', new_sort);
                        window.location.reload();
                    }
                })
            }
        });

        $('.sp_delete').on('click', function (e) {
            e.preventDefault();
            var url = $(this).attr('href');
            layer.msg('确定删除？', {
                time: 0, //不自动关闭
                btn: ['确定', '取消'],
                yes: function(index){
                    layer.close(index);
                    $.get(url, function(re) {
                        if (re.status) {
                            window.location.reload();
                        }
                    })
                }
            });
        });
    })
</script>
</body>
</html>